//
//  NYEditManager.m
//  Nooryes
//
//  Created by baken on 2020/3/7.
//  Copyright © 2020 MyApp. All rights reserved.
//

#import "NYEditManager.h"
#import "NYMainModel.h"

@implementation NYEditManager


+(void)modifyPasswordWithPhone:(NSString *)phone andNewPass:(NSString *)pwd andCode:(NSString *)code andCompletionHandle:(void (^)(NYMainModel *model, NSError *error))complete{
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setValue:phone forKey:@"phone"];
    [dict setValue:pwd forKey:@"upass"];
    [dict setValue:code forKey:@"code"];
    
    [self POST:[NSString stringWithFormat:@"%@%@",Api_URL,kModifyPassword]
    parameters:dict
completionHandler:^(id responseObj, NSError *error) {
        NYMainModel *model = [NYMainModel mj_objectWithKeyValues:responseObj];
        if (model.code != 0) {
            error = [self createError:model.msg];
        }
        complete(model,error);
    }];
}

+(void)resetPhoneWithUserID:(NSString *)userID andSessionID:(NSString *)sessionID andPhone:(NSString *)phone andCode:(NSString *)code andCompletionHandle:(void (^)(NYMainModel *model, NSError *error))complete{
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setValue:phone forKey:@"phone"];
    [dict setValue:userID forKey:@"userid"];
    [dict setValue:sessionID forKey:@"sessionid"];
    [dict setValue:code forKey:@"code"];
    
    [self POST:[NSString stringWithFormat:@"%@%@",Api_URL,kResetPhone]
    parameters:dict
completionHandler:^(id responseObj, NSError *error) {
        NYMainModel *model = [NYMainModel mj_objectWithKeyValues:responseObj];
        if (model.code != 0) {
            error = [self createError:model.msg];
        }
        complete(model,error);
    }];
}


@end
